﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Net;
using System.Net.Mail;
using System.Net.Configuration;
using OsPortal;
using System.Data.SqlClient;
using System.Data;
using System.IO;
using System.Text;
using System.Xml;
using System.Web.Caching;


/// <summary>
/// Summary description for clsCommon
/// </summary>
/// 


public static class basConst
{
    public const string POSTSIGN = "99999999";
    public const string PR_USERCONTROL_NAME = "mo";

    //Thời gian sống của cache
    public const int timeCache = 30;
    //Thời gian sống của cookie 30 ngay
    public const int timeCookie = 30;

    //Cookie
    public const string COOKIE_USER_INFO = "userInfo_cookie";
    public const string COOKIE_USER_ID = "US_ID";
    public const string COOKIE_USER_NAME = "us_hoten";
    public const string COOKIE_USER_EMAIL = "us_email";
    public const string COOKIE_USER_LASTLOGIN = "us_lastlogin";

    //QueryString
    public const string QR_URL_REDERECT = "rturl";
    public const string QR_URL_PTID = "pt_id";

    //MOD-ACTION====================================================
    public const string MOD_ADD = "A";
    public const string MOD_UPDATE = "U";
    public const string MOD_DELETE = "D";
    public const string MOD_CHANGE = "C";

    // TRANG HIỆN TẠI
    public const int CURENT_PAGE = 1;
    //So luong san pham / 1 trang
    public const int PROC_NUMBER = 30;
    public const int PROC_NUMBER_SMALL = 20;
    public const int NEWS_NUMBER = 2;
    //Message system
    public const string DATAISNULL="Không có dữ liệu";
    //Duong dan luu tru
    public const string PATH_IMAGES_USER = "~/Images/UsersUpload/";

    // ĐƯỜNG DẪN LƯU TRỮ FILE TEXT
    public const string LinkGA_Index = "SaveFile/GA/Index-GA.txt";
    public const string LinkGA_HeaderCode = "SaveFile/GA/CodeHeader.txt";
    public const string LinkGA_Left = "SaveFile/GA/Left-GA.txt";
    public const string LinkGA_Right = "SaveFile/GA/Right-GA.txt";
    public const string LinkGA_Mid = "SaveFile/GA/Mid-GA.txt";
    public const string LinkFormMailActiveAccount = "SaveFile/FormMailActiveAccount.txt";
    public const string LinkFormGetPassword = "SaveFile/FormGetPassWord.txt";
    public const string LinkFormMailGopY = "SaveFile/FormMailGopY.txt";
    public const string LinkPOPUP_AV_Index = "SaveFile/Popup_AV_Index.txt";
    public const string LinkLienKetLogo = "SaveFile/LienKetLogo.txt";
    public const string LinkSlideQuangCao = "SaveFile/Slide_AV_Master.txt";
    public const string LinkQuangCao_LEFT = "SaveFile/Left_AV.txt";
    public const string LinkTextLink = "SaveFile/TextLink.txt";
    public const string LinkQuangCao_Top_VIP = "SaveFile/QuangCao_Top_VIP.txt";
    //
    public const string PT_TOAN_QUOC = "toan-quoc";
    //
    public const string KP_TAT_CA = "cho-thue-phong-tro-nha-tro";
    public static string[] gstrNhaMangGameBank = { "", "Viettel", "Mobifone", "Vinaphone", "Gate", "VTC" };

    //SESSTION
    public const string SESSTION_MOBILE_STATUS = "mobile_status";
    //
    public const string MOBILE_STATUS_NULL = "NULL";
    public const string MOBILE_STATUS_TRUE = "TRUE";
    public const string MOBILE_STATUS_FALSE = "FALSE";
}
/*------------------------------------------------------------*/


public static class clsCommon
{
    static string strClassName = "clsCommon";

    /// <summary>
    /// Lấy IP của máy đang truy cập
    /// </summary>
    /// <returns></returns>
    public static string fncGetClientIP()
    {
        string ipList = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

        if (!string.IsNullOrEmpty(ipList))
        {
            return ipList.Split(',')[0];
        }

        return HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
    }

    /// <summary>
    /// Get Route
    /// </summary>
    /// <param name="objPage">this.Page</param>
    /// <param name="strParam">Param</param>
    /// <returns></returns>
    public static string fncGetRoute(System.Web.UI.Page objPage, string strParam)
    {
        return OsPortal.oStringHelper.fncCnvNullToString(objPage.RouteData.Values[strParam]);
    }

    /// <summary>
    /// Tự động load UserControl
    /// </summary>
    /// <param name="plhControl">PlaceHolderID</param>
    /// <param name="objPage">This.Page</param>
    /// <param name="strFolderUrl">Thư mục chứa userControl</param>
    /// <param name="strUCDefault">UserControl mặc định</param>
    public static void fncLoadUserControl(PlaceHolder plhControl, System.Web.UI.Page objPage, string strFolderUrl, string strUCDefault)
    {
        string Param = HttpContext.Current.Request.QueryString.Get(basConst.PR_USERCONTROL_NAME);
        fncLoadUserControl(plhControl, objPage, strFolderUrl, Param, strUCDefault);
    }

    /// <summary>
    /// Tự động load UserControl
    /// </summary>
    /// <param name="plhControl">PlaceHolderID</param>
    /// <param name="objPage">This.Page</param>
    /// <param name="strFolderUrl">Thư mục chứa userControl</param>
    /// <param name="strUCDefault">UserControl mặc định</param>
    public static void fncLoadUserControl(PlaceHolder plhControl, System.Web.UI.Page objPage, string strFolderUrl, string strControName, string strUCDefault)
    {
        string Param = strControName;
        try
        {
            if (!string.IsNullOrEmpty(Param))
            {
                string str = strFolderUrl + Param.ToString() + ".ascx";
                plhControl.Controls.Add(objPage.LoadControl(str));
            }
            else
            {
                Param = strUCDefault;
                string str = strFolderUrl + Param.ToString() + ".ascx";
                plhControl.Controls.Add(objPage.LoadControl(str));
            }
        }
        catch (Exception ex)
        {
            //OsPortal.oFileHelper.WriteLogErr(strClassName, "fncLoadUserControl()", ex.ToString());
            HttpContext.Current.Response.Redirect("/404");
        }
    }


    /// <summary>
    /// Tự động tạo mã để insert vào CSDL
    /// </summary>
    /// <param name="strTienTo">Tiền Tố Của Mã VD: TD</param>
    /// <param name="strTenBang">Tên bảng</param>
    /// <param name="strTenKhoaChinh">Tên khóa chính</param>
    /// <returns></returns>
    public static string fncAutoCreateID(string strTienTo, string strTenBang, string strTenKhoaChinh)
    {
        DataTable dt = oSqlDataHelper.sExecuteDataTable("select max(" + strTenKhoaChinh + ") 'id' from " + strTenBang + "", null);
        Console.Write(dt.Rows.Count);

        try
        {
            string strMaCuoiCung = dt.Rows[0]["id"].ToString();
            string kq = "";
            int so = int.Parse(strMaCuoiCung.Substring(2));
            if (so + 1 < 999999)
                kq = strTienTo + (so + 1);
            if (so + 1 < 100000)
                kq = strTienTo + "0" + (so + 1);
            if (so + 1 < 10000)
                kq = strTienTo + "00" + (so + 1);
            if (so + 1 < 1000)
                kq = strTienTo + "000" + (so + 1);
            if (so + 1 < 100)
                kq = strTienTo + "0000" + (so + 1);
            if (so + 1 < 10)
                kq = strTienTo + "00000" + (so + 1);

            return kq;
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncAutoCreateID", ex.ToString());
            return strTienTo + "000001";
        }
    }

    /// <summary>
    /// Trả về phần đầu của chuỗi và đảm bảo đủ từ
    /// </summary>
    /// <param name="s"></param>
    /// <param name="length">Số ký tự tối đa được cắt</param>
    /// <returns>Chuoi can cat</returns>
    public static string fncCatChuoi(string s, int length)
    {
        if (String.IsNullOrEmpty(s))
            return "";
        var words = s.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (words[0].Length > length)
            return s;
        var sb = new StringBuilder();
        foreach (var word in words)
        {
            if ((sb + word).Length > length)
                return string.Format("{0}...", sb.ToString().TrimEnd(' '));
            sb.Append(word + " ");
        }
        return string.Format("{0}...", sb.ToString().TrimEnd(' '));
    }

    /// <summary>
    /// Lấy một chuỗi ngẫu nhiên
    /// </summary>
    /// <param name="codeCount">Số lượng ký tự</param>
    /// <returns></returns>
    public static string NgauNhien_SoChu(int codeCount)
    {
        string allChar = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
        string[] allCharArray = allChar.Split(',');
        string randomCode = "";
        int temp = -1;

        Random rand = new Random();
        for (int i = 0; i < codeCount; i++)
        {
            if (temp != -1)
            {
                rand = new Random(i * temp * ((int)DateTime.Now.Ticks));
            }
            int t = rand.Next(36);
            if (temp != -1 && temp == t)
            {
                return NgauNhien_SoChu(codeCount);
            }
            temp = t;
            randomCode += allCharArray[t];
        }
        return randomCode;
    }

}

/*---------------------public calss expost HTLML------------------*/
public class clsExportHtml
{
    static string strClassName = "clsExportHtml";
    /// <summary>
    /// Export HTML danh sách phòng trọ
    /// Author: ThuanNH
    /// Create Date: 2013/08/01
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportPhongTro(DataTable dtSource)
    {
        StringBuilder sbHtmlPhongTro = new StringBuilder("");
        try
        {
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strPT_ID = dtSource.Rows[i]["PT_ID"].ToString().ToLower();
                string strPT_TIEUDE = dtSource.Rows[i]["PT_TIEUDE"].ToString();
                string strTIEUDEKHONGDAU = dtSource.Rows[i]["PT_TIEUDEKHONGDAU"].ToString();
                string strPT_DIACHI = dtSource.Rows[i]["PT_DIACHI"].ToString();
                string strPT_GIAPHONG = String.Format("{0:0,0 vnđ}", dtSource.Rows[i]["PT_GIAPHONG"]);
                string strPT_DIENTICH = String.Format("{0:0,0 m2}", dtSource.Rows[i]["PT_DIENTICH"]);
                string strPT_LUOTXEM = dtSource.Rows[i]["PT_LUOTXEM"].ToString();
                string strPT_NGAYCAPNHAT = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(dtSource.Rows[i]["PT_NGAYCAPNHAT"]));
                string strPT_KIEUPHONG = dtSource.Rows[i]["KP_TENKHONGDAU"].ToString().ToLower();
                string strPT_KHUVUC = dtSource.Rows[i]["KV_TENKHONGDAU"].ToString().ToLower();
                string strKP_ICON = dtSource.Rows[i]["KP_ICON"].ToString();
                string strKP_COLOR = dtSource.Rows[i]["KP_COLOR"].ToString();
                string strKV_TEN = dtSource.Rows[i]["KV_TEN"].ToString();
                string strANH_1 = dtSource.Rows[i]["PT_ANH1"].ToString();
                string strPT_NGAYBATDAU=dtSource.Rows[i]["PT_NGAYBATDAU"].ToString();
                string strPT_NGAYKETTHUC=dtSource.Rows[i]["PT_NGAYKETTHUC"].ToString();
                string strPT_GIOBATDAU=dtSource.Rows[i]["PT_GIOBATDAU"].ToString();
                string strPT_GIOKETTHUC=dtSource.Rows[i]["PT_GIOKETTHUC"].ToString();
                string strPT_PHUTBATDAU=dtSource.Rows[i]["PT_PHUTBATDAU"].ToString();
                string strPT_PHUTKETTHUC=dtSource.Rows[i]["PT_PHUTKETTHUC"].ToString();

                if (string.IsNullOrEmpty(strANH_1.Trim())) strANH_1 = "/Images/System/noimg_temp.jpg";
                else strANH_1 = "/" + strANH_1;
                //
                string strMotaCT = OsPortal.oStringHelper.ClearTagHTML(dtSource.Rows[i]["PT_MOTACHITIET"].ToString());
                strMotaCT = OsPortal.oStringHelper.CatChuoi(strMotaCT, 350);
                strMotaCT = strMotaCT.Replace("\r", "");
                strMotaCT = strMotaCT.Replace("\n", "");
                //
                string strURL = "/" + strPT_KIEUPHONG + "/" + strPT_KHUVUC + "/" + strTIEUDEKHONGDAU + "-" + strPT_ID;
                string strTime = "Ngày " + strPT_NGAYBATDAU + ", lúc " + strPT_GIOBATDAU + "h" + strPT_PHUTBATDAU + " | ";
                sbHtmlPhongTro.Append("<div class='itemPTVip'>");
                sbHtmlPhongTro.Append("<a href='" + strURL + "' title='" + strPT_TIEUDE + "'><div class='img-pt-vip'><img src='" + strANH_1 + "' alt='" + strPT_TIEUDE + "'></div></a>");
                sbHtmlPhongTro.Append("<div class='description-pt-vip'>");
                sbHtmlPhongTro.Append("<h3><a href='" + strURL + "' onmouseover='showtip(\"" + strMotaCT + "\");' onmouseout='hidetip();'>" + strPT_TIEUDE + "</a></h3>");
                sbHtmlPhongTro.Append("<div class='time-even' style='font-size: 12px;'><b>Thời gian: </b>" + strTime  + strPT_LUOTXEM + " lượt xem</div>");
                sbHtmlPhongTro.Append("<div class='place-even'><b>Địa chỉ:</b> " + strPT_DIACHI + "</div>");
                //sbHtmlPhongTro.Append("<p><b>Giá phòng:</b> " + strPT_GIAPHONG + " | <b>Diện tích:</b> " + strPT_DIENTICH + " | <b>Lượt xem:</b> " + strPT_LUOTXEM + "</p>");
                sbHtmlPhongTro.Append("</div>");
                //sbHtmlPhongTro.Append("<div class='lstCTright'><p style='color: Red;'><b>" + strKV_TEN + "</b></p><p>" + strPT_NGAYCAPNHAT + "</p></div>");
                sbHtmlPhongTro.Append("<div class='clr'></div>");
                sbHtmlPhongTro.Append("</div>");
            }
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportPhongTro", ex.ToString());
        }
        return sbHtmlPhongTro.ToString();
    }

    /// <summary>
    /// Export HTML danh sách phòng trọ cho quản lý user
    /// Author: ThuanNH
    /// Create Date: 2013/09/14
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportPhongTro_UserManager(DataTable dtSource)
    {
        string lstPhongTro = "";
        try
        {
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strPT_ID = dtSource.Rows[i]["PT_ID"].ToString().ToLower();
                string strPT_TIEUDE = dtSource.Rows[i]["PT_TIEUDE"].ToString();
                string strTIEUDEKHONGDAU = dtSource.Rows[i]["PT_TIEUDEKHONGDAU"].ToString();
                string strPT_DIACHI = dtSource.Rows[i]["PT_DIACHI"].ToString();
                string strPT_GIAPHONG = String.Format("{0:0,0 vnđ}", dtSource.Rows[i]["PT_GIAPHONG"]);
                string strPT_DIENTICH = String.Format("{0:0,0 m2}", dtSource.Rows[i]["PT_DIENTICH"]);
                string strPT_LUOTXEM = dtSource.Rows[i]["PT_LUOTXEM"].ToString();
                string strPT_NGAYCAPNHAT = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(dtSource.Rows[i]["PT_NGAYCAPNHAT"]));
                string strPT_KIEUPHONG = dtSource.Rows[i]["KP_TENKHONGDAU"].ToString().ToLower();
                string strKP_TEN = dtSource.Rows[i]["KP_TEN"].ToString();
                string strPT_KHUVUC = dtSource.Rows[i]["KV_TENKHONGDAU"].ToString();
                string strKP_ICON = dtSource.Rows[i]["KP_ICON"].ToString();
                string strKP_COLOR = dtSource.Rows[i]["KP_COLOR"].ToString();
                string strKV_TEN = dtSource.Rows[i]["KV_TEN"].ToString();
                string strTrangThaiPhong = dtSource.Rows[i]["PT_CONPHONG"].ToString();
                string strANH_1 = dtSource.Rows[i]["PT_ANH1"].ToString();
                //
                int iSoNgayDang = OsPortal.oStringHelper.fncCnvNullToInt(dtSource.Rows[i]["pt_songaydattinvip"]);
                DateTime dtNgayBatDau = Convert.ToDateTime(dtSource.Rows[i]["pt_ngaybatdaudattinvip"]);
                DateTime dtNgayHetHan = dtNgayBatDau.AddDays(iSoNgayDang);
                //
                //
                string strMotaCT = OsPortal.oStringHelper.ClearTagHTML(dtSource.Rows[i]["PT_MOTACHITIET"].ToString());
                strMotaCT = OsPortal.oStringHelper.CatChuoi(strMotaCT, 350);
                strMotaCT = strMotaCT.Replace("\r", "");
                strMotaCT = strMotaCT.Replace("\n", "");
                //
                string strURL = "/" + strPT_KIEUPHONG + "/" + strPT_KHUVUC + "/" + strTIEUDEKHONGDAU + "-" + strPT_ID;
                //
                lstPhongTro += "<div class='item_phongtro'>";
                lstPhongTro += "<div class='main_img_pt'>";
                lstPhongTro += "<a target='_blank' href='" + strURL + "'>";
                lstPhongTro += "<img src='/" + strANH_1 + "' onerror='this.src=\"/Images/System/no_image.gif\"' class='show_main_img' />";
                lstPhongTro += "</a>";
                lstPhongTro += "</div>";
                lstPhongTro += "<div class='info_item_pt'>";
                lstPhongTro += "<div class='sub_info_phongtro'>";
                if (DateTime.Now <= dtNgayHetHan)
                {
                    lstPhongTro += "<b style='color:red; float:left;'>[VIP]&nbsp&nbsp</b>  ";
                }
                lstPhongTro += "<a target='_blank' href='" + strURL + "' onmouseover='showtip(\"" + strMotaCT + "\");' onmouseout='hidetip();'>";
                lstPhongTro += "<h2>" + strPT_TIEUDE + "</h2>";
                lstPhongTro += "</a>";
                lstPhongTro += "</div>";
                lstPhongTro += "<div class='pt_view'>";
                lstPhongTro += "<div>";
                lstPhongTro += "<span>Mã tin: </span><span id='pt_id'>" + strPT_ID + "</span>";
                lstPhongTro += "<span> - Ngày cập nhật: </span><span>" + strPT_NGAYCAPNHAT + "</span>";
                lstPhongTro += "</div>";
                lstPhongTro += "<div>";
                lstPhongTro += "<span class='view-on'></span><b><span id='pt_view'>" + strPT_LUOTXEM + "</span> - </b>";
                lstPhongTro += "<span>Chuyên mục: </span><b><a href='#' class='cm-detail'>" + strKP_TEN + "</a></b>";
                lstPhongTro += "<span> - Khu Vực: </span><b><a href='#' class='cm-detail'>" + strKV_TEN + "</a></b>";
                lstPhongTro += "</div>";
                if (DateTime.Now <= dtNgayHetHan)
                {
                    lstPhongTro += "<div style='float:left;margin-left:-15px;'>Ngày hết hạn tin VIP:&nbsp&nbsp<b style='color:red;'>" + String.Format("{0:dd/MM/yyyy HH:mm:ss}", dtNgayHetHan) + "</b></div>";
                }
                lstPhongTro += "</div>";
                lstPhongTro += "</div>";
                lstPhongTro += "<div class='even-item-vip'>";
                lstPhongTro += "<span class='w8-button red btnUpViP_pt_manager' href='/default-popup.aspx?mo=phong-tro-up-vip&" + basConst.QR_URL_PTID + "=" + strPT_ID + "' title='Đưa tin lên vị trí VIP có lượt truy cập gấp 20 lần tin thường'>▲ Đưa lên vị trí VIP</span>";
                lstPhongTro += "<span style='margin-top:5px; width:112px;' class='w8-button l-blue btnAutoUp_pt_manager' href='/Default-Popup.aspx?mo=phong-tro-up-tu-dong&" + basConst.QR_URL_PTID + "=" + strPT_ID + "' title='Đặt thời gian để tin tự động up lên đầu'>▲ Up tin tự động</span>";
                lstPhongTro += "</div>";
                lstPhongTro += "<div class='even-item'>";
                lstPhongTro += "<div class='wrap-even'>";
                lstPhongTro += "<a href='/dang-tin/" + strPT_ID + "' class='evn_item_style'>Sửa</a>";
                lstPhongTro += "<a href='javascript:void(0)' class='evn_item_style btnDeletePT'>Xóa</a>";
                lstPhongTro += "<a href='javascript:void(0)' class='evn_item_style btnResetViews'>Làm mới lượt xem</a>";
                lstPhongTro += "<a href='javascript:void(0)' class='evn_item_style btnUpTin'>Up tin lên trang chủ</a>";
                if (strTrangThaiPhong == "True")
                {
                    lstPhongTro += "<a href='javascript:void(0)' class='evn_item_style btnTatTin'>Tắt tin</a>";
                }
                else if (strTrangThaiPhong == "False") { lstPhongTro += "<a href='javascript:void(0)' style='color:red !important;' class='evn_item_style btnBatTin'>Bật tin</a>"; }
                lstPhongTro += "</div>";
                lstPhongTro += "</div>";
                lstPhongTro += "<div class='clr'></div>";
                lstPhongTro += "</div>";
            }
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportPhongTro", ex.ToString());
        }
        return lstPhongTro;
    }

    /// <summary>
    /// Export HTML danh sách phòng trọ VIP
    /// Author: ThuanNH
    /// Create Date: 2013/08/01
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportPhongTro_VIP(DataTable dtSource)
    {
        //string lstPhongTro = "";
        StringBuilder sbHtmlPhongTro = new StringBuilder("");
        try
        {
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strPT_ID = dtSource.Rows[i]["PT_ID"].ToString().ToLower();
                string strPT_TIEUDE = dtSource.Rows[i]["PT_TIEUDE"].ToString();
                string strTIEUDEKHONGDAU = dtSource.Rows[i]["PT_TIEUDEKHONGDAU"].ToString();
                string strPT_DIACHI = dtSource.Rows[i]["PT_DIACHI"].ToString();
                string strPT_GIAPHONG = String.Format("{0:0,0 vnđ}", dtSource.Rows[i]["PT_GIAPHONG"]);
                string strPT_DIENTICH = String.Format("{0:0,0 m2}", dtSource.Rows[i]["PT_DIENTICH"]);
                string strPT_LUOTXEM = dtSource.Rows[i]["PT_LUOTXEM"].ToString();
                string strPT_NGAYCAPNHAT = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(dtSource.Rows[i]["PT_NGAYCAPNHAT"]));
                string strPT_KIEUPHONG = dtSource.Rows[i]["KP_TENKHONGDAU"].ToString().ToLower();
                string strPT_KHUVUC = dtSource.Rows[i]["KV_TENKHONGDAU"].ToString().ToLower();
                string strKP_ICON = dtSource.Rows[i]["KP_ICON"].ToString();
                string strKP_COLOR = dtSource.Rows[i]["KP_COLOR"].ToString();
                string strKP_TEN = dtSource.Rows[i]["KP_TEN"].ToString();
                string strKV_TEN = dtSource.Rows[i]["KV_TEN"].ToString();
                string strANH_1 = dtSource.Rows[i]["PT_ANH1"].ToString();
                if (string.IsNullOrEmpty(strANH_1.Trim())) strANH_1 = "/Images/System/no_image.gif";
                else strANH_1 = "/" + strANH_1;
                //
                string strMotaCT = OsPortal.oStringHelper.ClearTagHTML(dtSource.Rows[i]["PT_MOTACHITIET"].ToString());
                strMotaCT = OsPortal.oStringHelper.CatChuoi(strMotaCT, 350);
                strMotaCT = strMotaCT.Replace("\r", "");
                strMotaCT = strMotaCT.Replace("\n", ""); 
                //
                string strURL = "/" + strPT_KIEUPHONG + "/" + strPT_KHUVUC + "/" + strTIEUDEKHONGDAU + "-" + strPT_ID;
                string strURLKieuPhong = "/" + strPT_KIEUPHONG + "/" + strPT_KHUVUC;

                sbHtmlPhongTro.Append("<div class='itemPTVip'>");
                sbHtmlPhongTro.Append("<div class='img-pt-vip'><img src='" + strANH_1 + "' alt='" + strPT_TIEUDE + "'></div>");
                sbHtmlPhongTro.Append("<div class='description-pt-vip'>");
                sbHtmlPhongTro.Append("<h3><a href='" + strURL + "' onmouseover='showtip(\"" + strMotaCT + "\");' onmouseout='hidetip();'>" + strPT_TIEUDE + "</a></h3>");
                sbHtmlPhongTro.Append("<p><b>Địa chỉ:</b> " + strPT_DIACHI + "</p>");
                sbHtmlPhongTro.Append("<p><b>Giá phòng:</b> " + strPT_GIAPHONG + " | <b>Diện tích:</b> " + strPT_DIENTICH + " | <b>Lượt xem:</b> " + strPT_LUOTXEM + " - <a style='color:#055699;' href='" + strURLKieuPhong + "'>" + strKP_TEN + "</a></p>");
                sbHtmlPhongTro.Append("</div>");
                sbHtmlPhongTro.Append("<div class='lstCTright'><p style='color: Red;'><b>" + strKV_TEN + "</b></p><p>" + strPT_NGAYCAPNHAT + "</p></div>");
                sbHtmlPhongTro.Append("<div class='clr'></div>");
                sbHtmlPhongTro.Append("</div>");
            }
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportPhongTro", ex.ToString());
        }
        return sbHtmlPhongTro.ToString();
    }

    /// <summary>
    /// Export HTML danh sách phòng trọ cùng khu vực.
    /// Author: NguyenTV
    /// Create Date: 02/08/2013
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportPhongTroSame(DataTable dtSource)
    {
        string lstPhongTro = "";
        try
        {
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strPT_ID = dtSource.Rows[i]["PT_ID"].ToString().ToLower();
                string strPT_TIEUDE = dtSource.Rows[i]["PT_TIEUDE"].ToString();
                string strTIEUDEKHONGDAU = dtSource.Rows[i]["PT_TIEUDEKHONGDAU"].ToString();
                string strPT_DIACHI = dtSource.Rows[i]["PT_DIACHI"].ToString();
                string strPT_GIAPHONG = String.Format("{0:0,0 vnđ}", dtSource.Rows[i]["PT_GIAPHONG"]);
                string strPT_DIENTICH = String.Format("{0:0,0 m2}", dtSource.Rows[i]["PT_DIENTICH"]);
                string strPT_LUOTXEM = dtSource.Rows[i]["PT_LUOTXEM"].ToString();
                string strPT_NGAYCAPNHAT = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(dtSource.Rows[i]["PT_NGAYCAPNHAT"]));
                string strPT_KIEUPHONG = dtSource.Rows[i]["KP_TENKHONGDAU"].ToString().ToLower();
                string strPT_KHUVUC = dtSource.Rows[i]["KV_TENKHONGDAU"].ToString().ToLower();
                string strKP_ICON = dtSource.Rows[i]["KP_ICON"].ToString();
                string strKP_COLOR = dtSource.Rows[i]["KP_COLOR"].ToString();
                string strKV_TEN = dtSource.Rows[i]["KV_TEN"].ToString();
                //
                string strURL = "/" + strPT_KIEUPHONG + "/" + strPT_KHUVUC + "/" + strTIEUDEKHONGDAU + "-" + strPT_ID;
                //
                lstPhongTro += "<div class='lstRow'>";
                lstPhongTro += "<div style='background-color: " + strKP_COLOR + "' class='lstCTleft'><img src='http://nato.vn/" + strKP_ICON + "' alt=''></div>";
                lstPhongTro += "<div class='lstMid'>";
                lstPhongTro += "<h3> <a href='" + strURL + "' onmouseover='' onmouseout='hidetip();' class='title'>" + strPT_TIEUDE + "</a></h3>";
                lstPhongTro += "<p style='font-size: 12px;'><b>Địa chỉ:</b>" + strPT_DIACHI + "</p>";
                lstPhongTro += "<p style='font-size: 12px;'><b>Giá phòng:</b> <span style='color: Red;'>" + strPT_GIAPHONG + "</span>| <b>Diện tích:" + strPT_DIENTICH + " |" + strPT_LUOTXEM + " lượt xem</b>";
                lstPhongTro += "</div>";
                lstPhongTro += "<div class='lstCTright'><p style='color: Red;'><b>" + strKV_TEN + "</b></p><p>" + strPT_NGAYCAPNHAT + "</p></div>";
                lstPhongTro += "<div class='clr'> </div>";
                lstPhongTro += "</div>";
            }
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportPhongTro", ex.ToString());
        }
        return lstPhongTro;
    }

    public static string fncExportControlTopNews20(DataTable dtSource)
    {
        string lstPhongTro = "";
        try
        {
            lstPhongTro += "<div class='box-left'><h4 class='title-left'>TIN MỚI NHẤT</h4><ul class='ul-top-pt'>";
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strPT_ID = dtSource.Rows[i]["PT_ID"].ToString().ToLower();
                string strPT_TIEUDE = dtSource.Rows[i]["PT_TIEUDE"].ToString();
                string strTIEUDEKHONGDAU = dtSource.Rows[i]["PT_TIEUDEKHONGDAU"].ToString();
                string strPT_DIACHI = dtSource.Rows[i]["PT_DIACHI"].ToString();
                string strPT_GIAPHONG = String.Format("{0:0,0 vnđ}", dtSource.Rows[i]["PT_GIAPHONG"]);
                string strPT_DIENTICH = String.Format("{0:0,0 m2}", dtSource.Rows[i]["PT_DIENTICH"]);
                string strPT_LUOTXEM = dtSource.Rows[i]["PT_LUOTXEM"].ToString();
                string strPT_NGAYCAPNHAT = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(dtSource.Rows[i]["PT_NGAYCAPNHAT"]));
                string strPT_KIEUPHONG = dtSource.Rows[i]["KP_TENKHONGDAU"].ToString().ToLower();
                string strPT_KHUVUC = dtSource.Rows[i]["KV_TENKHONGDAU"].ToString().ToLower();
                string strKP_ICON = dtSource.Rows[i]["KP_ICON"].ToString();
                string strKP_COLOR = dtSource.Rows[i]["KP_COLOR"].ToString();
                string strKV_TEN = dtSource.Rows[i]["KV_TEN"].ToString();
                string strIMG = dtSource.Rows[i]["PT_ANH1"].ToString();
                //
                string strURL = "/" + strPT_KIEUPHONG + "/" + strPT_KHUVUC + "/" + strTIEUDEKHONGDAU + "-" + strPT_ID;
                //
                lstPhongTro += "<li>";
                lstPhongTro += "<div class='divImg' style='border:1px solid #c0c0c0;'><img src='/" + strIMG + "' alt='" + strTIEUDEKHONGDAU + "' onerror='this.src=\"/Images/System/no_image.gif\"'></div>";
                lstPhongTro += "<h3><a href='" + strURL + "' onmouseover='' onmouseout='hidetip();' class='title'>" + strPT_TIEUDE + "</a></h3>";
                lstPhongTro += "</li>";
            }
            lstPhongTro += "</ul><div class='clr'></div></div>";
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportPhongTro", ex.ToString());
        }
        return lstPhongTro;
    }

    //public static string fncExportPhongTrobyUser(DataTable dtSource)
    //{
    //    string lstPhongTro = "";
    //    try
    //    {
    //        for (int i = 0; i < dtSource.Rows.Count; i++)
    //        {
    //            string strPT_ID = dtSource.Rows[i]["PT_ID"].ToString().ToLower();
    //            string strPT_TIEUDE = dtSource.Rows[i]["PT_TIEUDE"].ToString();
    //            string strTIEUDEKHONGDAU = dtSource.Rows[i]["PT_TIEUDEKHONGDAU"].ToString();
    //            string strPT_DIACHI = dtSource.Rows[i]["PT_DIACHI"].ToString();
    //            string strPT_LUOTXEM = dtSource.Rows[i]["PT_LUOTXEM"].ToString();
    //            string strPT_NGAYCAPNHAT = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(dtSource.Rows[i]["PT_NGAYCAPNHAT"]));
    //            string strPT_KIEUPHONG = dtSource.Rows[i]["KP_TENKHONGDAU"].ToString().ToLower();
    //            string strPT_KHUVUC = dtSource.Rows[i]["KV_TENKHONGDAU"].ToString().ToLower();
    //            string strImage1 = dtSource.Rows[i]["pt_anh1"].ToString().ToLower();
    //            //
    //            string strURL = "/" + strPT_KIEUPHONG + "/" + strPT_KHUVUC + "/" + strTIEUDEKHONGDAU + "-" + strPT_ID;
    //            //
    //            lstPhongTro += "<div class='item_phongtro'>";
    //            lstPhongTro += "<a href='" + strURL + "' class='main_img_pt'><img src='/"+strImage1+"' class='show_main_img' /></a>";
    //            lstPhongTro += "<div class='info_item_pt'><div class='sub_info_phongtro'><a href='" + strURL + "'><h2>" + strPT_TIEUDE + "</h2></a></div>";
    //            lstPhongTro += "<div class='pt_view'><p>ID tin: "+strPT_ID+"</p><span class='timeD'>"+strPT_NGAYCAPNHAT+" - </span><span class='view-on'></span><b>"+strPT_LUOTXEM+" - </b><span>Chuyên mục: </span><b><a href='"+strURL+"' class='cm-detail'>"+strPT_KIEUPHONG+"</a> | </b> <span><a href='"+strURL+"'>Xóa</a></span></div></div>";
    //            lstPhongTro += "<div class='even-item'><div class='wrap-even'>";
    //            lstPhongTro += "<a href=#' class='evn_item_style'>Sửa</a><a href='#' class='evn_item_style'>Up tin tự động</a><a href='#' class='evn_item_style'>Làm mới lượt xem</a><a href='#' class='evn_item_style'>Up tin lên trang chủ</a></div></div>";
    //            lstPhongTro += "<div class='clr'></div></div>";
    //        }
    //    }
    //    catch (Exception ex)
    //    {
    //        OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportPhongTrobyUser", ex.ToString());
    //    }
    //    return lstPhongTro;
    //}


    /// <summary>
    /// Export HTML Control kéo thả kiểu phòng trọ
    /// Author: NguyenTV
    /// CreateDate: 09/08/2013 
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportKieuPhongTroControl(DataTable dtSource)
    {
        string lstKieuPhongTro = "";

        try
        {
            //lstKieuPhongTro += "<div class='box-left'>";
            //lstKieuPhongTro += "<h4 class='title-left'>Bạn cần tìm?</h4>";
            //lstKieuPhongTro += "<div class='lst-icon'>";
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strKP_TENKHONGDAU = dtSource.Rows[i]["kp_tenkhongdau"].ToString().ToLower();
                string strKP_ICON = dtSource.Rows[i]["kp_icon"].ToString();
                string strKP_TEN = dtSource.Rows[i]["kp_ten"].ToString();
                string strKP_COLOR = dtSource.Rows[i]["kp_color"].ToString();

                string strLink = "/" + strKP_TENKHONGDAU + "/" + basConst.PT_TOAN_QUOC + "/0/0/1";

                lstKieuPhongTro += "<a href='" + strLink + "' title='" + strKP_TEN + "' class='nav-item'>";
                //lstKieuPhongTro += "<img src='/" + strKP_ICON + "' alt='" + strKP_TEN + "' title='" + strKP_TEN + "'/>";
                lstKieuPhongTro += "<h2>" + strKP_TEN + "</h2>";
                lstKieuPhongTro += "</a>";
            }
            //lstKieuPhongTro += "<div class='clr'></div>";
            //lstKieuPhongTro += "</div>";
            //lstKieuPhongTro += "</div>";
        }
        catch (Exception ex)
        {

            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportKieuPhongTroControl", ex.ToString());
        }

        return lstKieuPhongTro;
    }

    public static string fncExportChuDeTintuc(DataTable dtSource)
    {
        string lstCDTinTuc = "";
        try
        {
            lstCDTinTuc += "<ul class='chird-tintuc'>";

            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strCD_TENKHONGDAU = dtSource.Rows[i]["cd_tenkhongdau"].ToString().ToLower();
                string strCD_TEN = dtSource.Rows[i]["cd_ten"].ToString();

                string strLink = "/tin-tuc/" + strCD_TENKHONGDAU + "/1";

                lstCDTinTuc += "<li>";
                lstCDTinTuc += "<a href='" + strLink + "'>"+strCD_TEN+"</a>";
                lstCDTinTuc += "</li>";
            }
            lstCDTinTuc += "</ul>";
        }
        catch (Exception ex)
        {

            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportChuDeTintuc", ex.ToString());
        }
        return lstCDTinTuc;
    }


    public static string fncExportSuKien_NoiBat(DataTable dtSource)
    {
        StringBuilder sbHtml = new StringBuilder("");
        try
        {
            var rows = dtSource.Rows.Count;
            for (int i = 0; i < rows; i++)
            {
                string strPT_ID = dtSource.Rows[i]["PT_ID"].ToString().ToLower();
                string strPT_TIEUDE = dtSource.Rows[i]["PT_TIEUDE"].ToString();
                string strPT_TIEUDEKHONGDAU = dtSource.Rows[i]["PT_TIEUDEKHONGDAU"].ToString();
                string strImg = dtSource.Rows[i]["PT_ANH1"].ToString();
                string strNGAYBATDAU = dtSource.Rows[i]["PT_NGAYBATDAU"].ToString().Replace('/','-');
                string strKHUVUC = dtSource.Rows[i]["KV_TENKHONGDAU"].ToString();
                string strURL = "/dao-tao/"+strKHUVUC+"/" + strPT_TIEUDEKHONGDAU + "-" + strPT_ID;
                if (i == rows - 1)
                {
                    sbHtml.Append("<li class='last-box'><a href='" + strURL + "'><img src='" + strImg + "' alt='" + strPT_TIEUDEKHONGDAU + "' onerror='this.src=\"/Images/System/no_image.gif\"' /></a>");
                }
                else
                {
                    sbHtml.Append("<li><a href='" + strURL + "'><img src='" + strImg + "' alt='" + strPT_TIEUDEKHONGDAU + "' onerror='this.src=\"/Images/System/no_image.gif\"' /></a>");
                }
                sbHtml.Append("<div class='title-news'><a href='" + strURL + "'>" + strPT_TIEUDE + "</a></div>");
                sbHtml.Append("<div class='title-news-date'><span>"+strNGAYBATDAU+"</span></div>");
                sbHtml.Append("</li>");
            }
            sbHtml.Append("<div class='clr'></div></ul></section>");
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportSuKien_NoiBat", ex.ToString());
        }

        return sbHtml.ToString();
    }

    /// <summary>
    /// Export HTML Tin nổi bật trên trang chủ
    /// Author: NguyenTV
    /// CreateDate: 09/09/2013
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportTinTuc_NoiBat(DataTable dtSource)
    {
        StringBuilder sbHtml = new StringBuilder("");
        try
        {
            var rows = dtSource.Rows.Count;
            for (int i = 0; i < rows; i++)
            {
                string strTI_ID = dtSource.Rows[i]["TI_ID"].ToString().ToLower();
                string strTI_TIEUDE = dtSource.Rows[i]["ti_tieude"].ToString();
                string strTI_TIEUDEKHONGDAU = dtSource.Rows[i]["ti_tieudekhongdau"].ToString();
                string strCD_TENKHONGDAU = dtSource.Rows[i]["CD_TENKHONGDAU"].ToString().ToLower(); ;
                string strTI_NOIDUNG = dtSource.Rows[i]["ti_noidung"].ToString();
                var lstLinks = OsPortal.oRegexHelper.getlstImageInContent(strTI_NOIDUNG);
                string strImg = "";
                if (lstLinks.Count > 0)
                {
                    strImg = lstLinks[0];
                }
                string strURL = "/tin-tuc/" + strTI_TIEUDEKHONGDAU + "-" + strTI_ID;
                if (i == rows - 1)
                {
                    sbHtml.Append("<li class='last-box'><a href='" + strURL + "'><img src='" + strImg + "' alt='" + strTI_TIEUDEKHONGDAU + "' onerror='this.src=\"/Images/System/no_image.gif\"' /></a>");
                }
                else { sbHtml.Append("<li><a href='" + strURL + "'><img src='" + strImg + "' alt='" + strTI_TIEUDEKHONGDAU + "' onerror='this.src=\"/Images/System/no_image.gif\"' /></a>"); 
                }
                sbHtml.Append("<div class='title-news'><a href='" + strURL + "'>" + strTI_TIEUDE + "</a></div>");
                sbHtml.Append("<div class='title-news-date'><span>22-10-2013</span></div>");
                sbHtml.Append("</li>");
            }
            sbHtml.Append("<div class='clr'></div></ul></section>");
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportTinTuc_NoiBat_TroControl", ex.ToString());
        }

        return sbHtml.ToString();
    }

    /// <summary>
    /// Export control Left Nổi Bật
    /// Author: NguyenTV - 06/10/2013
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportLeft_NoiBat(DataTable dtSource)
    {
        string lstTintuc = "";

        try
        {
            
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strTI_ID = dtSource.Rows[i]["TI_ID"].ToString().ToLower();
                string strTI_TIEUDE = dtSource.Rows[i]["ti_tieude"].ToString();
                string strTI_TIEUDEKHONGDAU = dtSource.Rows[i]["ti_tieudekhongdau"].ToString();
                string strCD_TENKHONGDAU = dtSource.Rows[i]["CD_TENKHONGDAU"].ToString().ToLower(); ;
                string strTI_NOIDUNG = dtSource.Rows[i]["ti_noidung"].ToString();
                var lstLinks = OsPortal.oRegexHelper.getlstImageInContent(strTI_NOIDUNG);
                string strImg = "";
                if (lstLinks.Count > 0)
                {
                    strImg = lstLinks[0];
                }
                string strURL = "/tin-tuc/" + strTI_TIEUDEKHONGDAU + "-" + strTI_ID;
                //
                lstTintuc += "<li><a href='"+strURL+"'>";
                lstTintuc += "<img src='" + strImg + "' alt='" + strTI_TIEUDEKHONGDAU + "' onerror='this.src=\"/Images/System/no_image.gif\"' />";
                lstTintuc += "<h3>"+strTI_TIEUDE+"</h3>";
                lstTintuc += "</li></a>";
               
            }
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportTinTuc_NoiBat_TroControl", ex.ToString());
        }

        return lstTintuc;
    }


    /// <summary>
    /// Export Tin Tức Danh Sách 
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportTinTucDanhSach(DataTable dtSource)
    {
        string lstTintuc = "";

            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strTI_ID = dtSource.Rows[i]["TI_ID"].ToString().ToLower();
                string strTI_TIEUDE = dtSource.Rows[i]["ti_tieude"].ToString();
                string strTI_TIEUDEKHONGDAU = dtSource.Rows[i]["ti_tieudekhongdau"].ToString();
                string strCD_TENKHONGDAU = dtSource.Rows[i]["CD_TENKHONGDAU"].ToString().ToLower();
                string strMOTA = dtSource.Rows[i]["ti_tomtat"].ToString().ToLower();
                string strTI_NOIDUNG = dtSource.Rows[i]["ti_noidung"].ToString();
                string strCREATE_DATE = OsPortal.oStringHelper.ConvertDateTime_to_String(Convert.ToDateTime(dtSource.Rows[0]["ti_ngaydangtin"]), 1);
                var lstLinks = OsPortal.oRegexHelper.getlstImageInContent(strTI_NOIDUNG);
                string strImg = "";
                if (lstLinks.Count > 0)
                {
                    strImg = lstLinks[0];
                }
                string strdeafaultImg = "this.src=\"/Images/System/no_image.gif\"";
                string strURL = "/tin-tuc/" + strTI_TIEUDEKHONGDAU + "-" + strTI_ID;

                lstTintuc += "<li><a href='"+ strURL +"'>";
                lstTintuc += "<img src='" + strImg + "' alt='" + strTI_TIEUDEKHONGDAU + "' onerror='"+strdeafaultImg+"' /></a>";
                lstTintuc += "<div class='content'><h2><a href='" + strURL + "'>" + strTI_TIEUDE + "</a></h2><br />";
                lstTintuc += "<div class='time-news'>" + strCREATE_DATE + "</div>";
                lstTintuc += "<div class='descriprion'>" + strMOTA + "</div>";
                lstTintuc += "</div></li>";
            }

            return lstTintuc;
    }


    /// <summary>
    /// Export HTML Tin Tức cùng chuyên mục
    /// Author: NguyenTV
    /// CreateDate: 09/09/2013
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportTinTucSame(DataTable dtSource)
    {
        string lstTintuc = "";

        try
        {
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strTI_ID = dtSource.Rows[i]["TI_ID"].ToString().ToLower();
                string strTI_TIEUDE = dtSource.Rows[i]["ti_tieude"].ToString();
                string strTI_TIEUDEKHONGDAU = dtSource.Rows[i]["ti_tieudekhongdau"].ToString();
                string strCD_TENKHONGDAU = dtSource.Rows[i]["CD_TENKHONGDAU"].ToString().ToLower(); ;
                string strTI_NOIDUNG = dtSource.Rows[i]["ti_noidung"].ToString();
                var lstLinks = OsPortal.oRegexHelper.getlstImageInContent(strTI_NOIDUNG);
                string strdeafaultImg = "this.src=\"/Images/System/no_image.gif\"";
                string strImg = "/Images/System/no_image.gif";
                if (lstLinks.Count > 0)
                {
                    strImg = lstLinks[0];
                }
                string strURL = "/tin-tuc/" + strTI_TIEUDEKHONGDAU + "-" + strTI_ID;

                lstTintuc += "<li class='same'><a title='" + strTI_TIEUDE + "' href='" + strURL + "'><img src='" + strImg + "' alt='" + strTI_TIEUDEKHONGDAU + "' onerror='" + strdeafaultImg + "' class='img-same' /></a>";
                lstTintuc += "<div class='title-news'><a title='" + strTI_TIEUDE + "' href='" + strURL + "'>" + strTI_TIEUDE + "</a>";
                lstTintuc += "</div></li>";
            }
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportTinTucSame", ex.ToString());
        }

        return lstTintuc;
    }

    /// <summary>
    /// Export HTML 1 tin theo chuyên mục
    /// Author: NguyenTV - 20/09/2013
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportOnlyOne(DataTable dtSource)
    {
        string lstTintuc = "";

        try
        {
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strTI_ID = dtSource.Rows[i]["TI_ID"].ToString().ToLower();
                string strTI_TIEUDE = dtSource.Rows[i]["ti_tieude"].ToString();
                string strTI_TIEUDEKHONGDAU = dtSource.Rows[i]["ti_tieudekhongdau"].ToString();
                string strCD_TENKHONGDAU = dtSource.Rows[i]["CD_TENKHONGDAU"].ToString().ToLower(); ;
                string strTI_MOTA = dtSource.Rows[i]["ti_tomtat"].ToString();
                string strTI_NOIDUNG = dtSource.Rows[i]["ti_noidung"].ToString();
                var lstLinks = OsPortal.oRegexHelper.getlstImageInContent(strTI_NOIDUNG);
                string strImg = "";
                if (lstLinks.Count > 0)
                {
                    strImg = lstLinks[0];
                }
                string strdeafaultImg = "this.src=\"/Images/System/no_image.gif\"";
                string strURL = "/tin-tuc/" + strTI_TIEUDEKHONGDAU + "-" + strTI_ID;

                lstTintuc += "<img src='" + strImg + "' alt='" + strTI_TIEUDEKHONGDAU + "' onerror='" + strdeafaultImg + "' />";
                lstTintuc += "<div class='description'><h2><a class='title' href='" + strURL + "'>" + strTI_TIEUDE + "</a></h2><br />" + strTI_MOTA + "</div>";
            }
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportTinTucSame", ex.ToString());
        }

        return lstTintuc;
    }

    /// <summary>
    /// Export HTML Danh sách tỉnh thành POPUP
    /// Author: NguyenTV
    /// CreateDate: 19/08/2013
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportTinhThanh_Popup(DataTable dtSource)
    {
        string lstTinhThanh = "";

        try
        {
            lstTinhThanh += "<div class='lvTinhThanh'>";
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strKV_ID = dtSource.Rows[i]["KV_ID"].ToString().ToLower();
                string strKV_ten = dtSource.Rows[i]["kv_ten"].ToString();
                string strKV_tenkhongdau = dtSource.Rows[i]["kv_tenkhongdau"].ToString().ToLower();
                string strURL = "/dao-tao/" + strKV_tenkhongdau;

                lstTinhThanh += "<div class='item'>";
                lstTinhThanh += "<a href='" + strURL + "'>" + strKV_ten + "</a>";
                lstTinhThanh += "</div>";
            }
            lstTinhThanh += "<div class='mapsVN'></div> <div class='clr'></div>";
            lstTinhThanh += "</div>";
        }
        catch (Exception ex)
        {

            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportTinhThanh_Popup", ex.ToString());
        }

        return lstTinhThanh;
    }

    /// <summary>
    /// Export html danh sách lịch sử nạp gold
    /// Author: Nguyentv -04/10/2013
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportLogGold(DataTable dtSource)
    {
        string lstLogGold = "";

        try
        {
            for (int i = 0; i < dtSource.Rows.Count;i++)
            {
                string strUsName = dtSource.Rows[i]["US_HOTEN"].ToString();
                string strLG_ID = dtSource.Rows[i]["NG_ID"].ToString();
                string strMenhGia = String.Format("{0:0,0 vnđ}", dtSource.Rows[i]["ng_menhgia"]);
                string strNgayNap = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(dtSource.Rows[i]["ng_ngaynap"]));
                string strNhaMang = dtSource.Rows[i]["ng_nhamang"].ToString();

                lstLogGold += "<div class='divGeneral'>";
                lstLogGold += "<div class='ngPre rowTable'>" + strUsName + "</div>";
                lstLogGold += "<div class='ngMG rowTable'>" + strMenhGia + "</div>";
                lstLogGold += "<div class='ngNN rowTable'>" + strNgayNap + "</div>";
                lstLogGold += "<div class='ngNM rowTable'>" + strNhaMang + "</div>";
                lstLogGold += "</div>";
            }
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName,"fncExportLogGold", ex.ToString());   
        }

        return lstLogGold;
    }

    /// <summary>
    /// Export HTML Khu vực dropdownlist
    /// Author: ThuanNH
    /// CreateDate: 25/09/2013
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportKhuVuc_DropDownList(DataTable dtSource, int iType)
    {
        string html = "";
        try
        {
            if (iType == 1)
                html += "<option kinhdo='0' vido='0' value='0'>Chọn Quận Huyện</option>";
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strKV_ID = dtSource.Rows[i]["KV_ID"].ToString().ToLower();
                string strKV_ten = dtSource.Rows[i]["kv_ten"].ToString();
                string strKV_tenkhongdau = dtSource.Rows[i]["kv_tenkhongdau"].ToString().ToLower();
                string strkv_kinhdo = dtSource.Rows[i]["kv_kinhdo"].ToString();
                string strkv_vido = dtSource.Rows[i]["kv_vido"].ToString();

                string strValue = strKV_ID;
                if (iType == 1) strValue = strKV_tenkhongdau;

                html += "<option kinhdo='" + strkv_kinhdo + "' vido='" + strkv_vido + "' value='" + strValue + "'>" + strKV_ten + "</option>";
            }
        }
        catch (Exception ex)
        {

            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportTinhThanh_Popup", ex.ToString());
        }

        return html;
    }

    /// <summary>
    /// Export HTML Vị trí đặt tin VIP
    /// Author: ThuanNH
    /// CreateDate: 01/10/2013
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportViTriVip_DropDownList(DataTable dtSource, int iType)
    {
        string html = "";
        try
        {
            if (iType == 1)
                html += "<option avatar='http://blog.olo.vn/wp-content/uploads/2012/06/VIP3.jpg' gold='0' value='0'>Chọn Vị Trí</option>";
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strGV_ID = dtSource.Rows[i]["GV_ID"].ToString().ToLower();
                string strgv_khuvuc = dtSource.Rows[i]["gv_khuvuc"].ToString();
                string strgv_gold = dtSource.Rows[i]["gv_gold"].ToString().ToLower();
                string strgv_avatar = dtSource.Rows[i]["gv_avatar"].ToString();

                html += "<option avatar='" + strgv_avatar + "' gold='" + strgv_gold + "' value='" + strGV_ID + "'>" + strgv_khuvuc + "</option>";
            }
        }
        catch (Exception ex)
        {

            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportViTriVip_DropDownList", ex.ToString());
        }

        return html;
    }

    /// <summary>
    /// Export HTML Noi Dung Hang So
    /// Author: NguyenTV
    /// CreateDate: 19/08/2013
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportHangSo(DataTable dtSource)
    {
        string lstTinhThanh = "";

        try
        {
            lstTinhThanh += "<div class='lvTinhThanh'>";
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strKV_ID = dtSource.Rows[i]["KV_ID"].ToString().ToLower();
                string strKV_ten = dtSource.Rows[i]["kv_ten"].ToString();
                string strKV_tenkhongdau = dtSource.Rows[i]["kv_tenkhongdau"].ToString().ToLower();
                string strURL = "/cho-thue-phong-tro/" + strKV_tenkhongdau;

                lstTinhThanh += "<div class='item'>";
                lstTinhThanh += "<a href='" + strURL + "'>" + strKV_ten + "</a>";
                lstTinhThanh += "</div>";
            }
            lstTinhThanh += "<div class='mapsVN'></div> <div class='clr'></div>";
            lstTinhThanh += "</div>";
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportTinhThanh_Popup", ex.ToString());
        }

        return lstTinhThanh;
    }

    /// <summary>
    /// Comment Facebook
    /// </summary>
    /// <returns></returns>
    public static string fncExportConmentFacebook()
    {
        return "<div class='fb-comments' data-href='" + HttpContext.Current.Request.Url.AbsoluteUri + "' data-width='714' data-num-posts='10'></div>";
    }

    /// <summary>
    /// Like Button
    /// </summary>
    /// <returns></returns>
    public static string fncLikeButton()
    {
        string strUrl = HttpContext.Current.Request.Url.AbsoluteUri;
        string strHtml = "<div class='g-plusone' data-href='" + strUrl + "'></div>";
        //strHtml += "<div class='fb-like' data-href='" + strUrl + "' data-colorscheme='light' data-layout='standard' data-action='like' data-show-faces='false' data-send='false'></div>";
        strHtml += "<div class='fb-like' style='margin-right:20px' data-href='"+ strUrl +"' data-width='250' data-layout='button_count' data-action='like' data-show-faces='false' data-share='false'></div>";
        strHtml += "<div class='fb-share-button' data-href='" + strUrl + "' data-width='50' data-type='button_count'></div>";
        //strHtml += "<div class='fb-share-button' data-href='" + strUrl + "' data-type='button_count' data-width='200'></div>";
        return strHtml;
    }

    /// <summary>
    /// Export HTML danh sách phòng trọ up tự động theo US_ID
    /// Author: NguyenTV
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportlstPT_AUTOUP(DataTable dtSource)
    {
        string lstHTML = "";
        try
        {
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strPT_ID = dtSource.Rows[i]["PT_ID"].ToString();
                string strTieuDe = dtSource.Rows[i]["PT_TIEUDE"].ToString();

                lstHTML += "<div class='divGeneral'>";
                lstHTML += "<div class='rowTable' style='width:15%;'>"+strPT_ID+"</div>";
                lstHTML += "<div class='rowTable' style='width:68.7%;text-align: left; padding-left: 5px;'>" + strTieuDe + "</div>";
                lstHTML += "<div class='rowTable' style='width:15%;'>";
                lstHTML += "<span class='w8-button l-blue btnSee_lst_Auto' href='/default-popup.aspx?mo=phong-tro-lst-auto&" + basConst.QR_URL_PTID + "=" + strPT_ID + "' style='line-height:25px;padding: 0px 15px;'>Xem</span>";
                lstHTML += "</div>";
                lstHTML += "</div>";

            }
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportlstPT_AUTOUP", ex.ToString());
        }
        return lstHTML;
    }

    /// <summary>
    /// Export HTML danh sách lịch up tin AUTO theo PT_ID
    /// Author: NguyenTV
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportlstAUTOUP_BYPT(DataTable dtSource)
    {
        string lstHTML = "";
        try
        {
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strPT_ID = dtSource.Rows[i]["PT_ID"].ToString();
                Int32 iAu_ID = Convert.ToInt32(dtSource.Rows[i]["AT_ID"].ToString());
                string strAu_time = OsPortal.oStringHelper.ConvertDateTime_to_String(Convert.ToDateTime(dtSource.Rows[i]["UP_TIME"]), 1);
                string strAu_time_edit = String.Format("{0:d/M/yyyy HH:mm}", dtSource.Rows[i]["UP_TIME"]);
                Int32 up_status = Convert.ToInt32(dtSource.Rows[i]["UP_STATUS"]);
                string strauStatus = "";
                if (up_status == 1)
                {
                    strauStatus = "<span style='color:green'>Đã up</span>";
                }
                else
                {
                    strauStatus = "<span style='color:red'>Chưa up</span>";
                }
                //
                lstHTML += "<div class='divGeneral boderD'>";
                lstHTML += "<div class='autoPMT rowPUT'>" + strPT_ID + "</div>";
                lstHTML += "<div class='autoPTG rowPUT'>" + strAu_time + "</div>";
                lstHTML += "<div class='autoPTT rowPUT'>" + strauStatus + "</div>";
                lstHTML += "</div>";

            }
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportlstPT_AUTOUP", ex.ToString());
        }
        return lstHTML;
    }

}